
#include <string>
#include "AddressEth.hpp"
#include "AddressIPv4.hpp"
#include "AddressIPv6.hpp"

namespace huluwa {
namespace net {

class Address {

public:

    Address() : type_(IPv4), ipv4Addr_(), ipv6Addr_(), ethAddr_() {}

    Address(AddressEth& eth) :
        type_(ETHERNET), ethAddr_(eth), ipv4Addr_(), ipv6Addr_() {}

    Address(AddressIPv4& ipv4) :
        type_(IPv4), ethAddr_(), ipv4Addr_(ipv4), ipv6Addr_() {}

    Address(AddressIPv6& ipv6) :
        type_(IPv6), ethAddr_(), ipv4Addr_(), ipv6Addr_(ipv6) {}

    ~Address() {}

    bool IsEthernet() 
    {
        return type_ == ETHERNET;
    }

    bool IsIPv4() 
    {
        return type_ == IPv4;
    }

    bool IsIPv6() 
    {
        return type_ == IPv6;
    }

    AddressEth ToEthernet()
    {

    }

    AddressIPv4 ToIPv4()
    {
    }

    AddressIPv6 ToIPv6()
    {

    }


    static Address FromString(const char *addr);
    {
    }

    static Address FromString(const char *addr, huluwa::sys::ErrorCode& ec);
    {

    }

    static Address FromString(const std::string& addr);
    {

    }
    static Address FromString(const std::string& addr, huluwa::sys::ErrorCode& ec);
    {

    }

    std::string ToString() const
    {

    }

    std::string ToString(huluwa::sys::ErrorCode& ec) const
    {

    }

private:

    enum {
        ETHERNET, IPV4, IPV6,
    } type_;

    AddressIPv4 ipv4Addr_;
    AddressIPv6 ipv6Addr_;
    AddressEth  ethAddr_;
}

} // namespace net
} // namespace huluwa
